import { createElement, serializeLabel } from '../utils'

/**
 * 列表线宽
 * @param expression
 * @param metadata
 */
export default (expression: any, { metadata }: any) => {
  const { stops } = expression
  return createElement('ul', {
    classes: ['list', 'list--line-width'],
    content: stops
      .sort((a: any, b: any) => a[1] - b[1]) // order from bigger to smaller
      .map(([value, width]: any) =>
        createElement('li', {
          styles: { '--width': `${width}px` },
          content: serializeLabel(value, metadata),
        })
      ),
  })
}
